package com.aat.dxfy.mq.t01;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

public class Producer {

	public static void main(String[] args) {
		try {
			DefaultMQProducer producer=new DefaultMQProducer("ProducerGroupName");
			producer.setNamesrvAddr("192.168.10.130:9876");
			producer.start();
			
			//
			{
				Message msg = new Message("TopicTest1",// topic
	                    "TagA",// tag
	                    "OrderID001",// key
	                    ("Hello MetaQ").getBytes());// body
	            SendResult sendResult = producer.send(msg);
	            System.out.println(sendResult);
			}
            
			{
				 Message msg = new Message("TopicTest2",// topic
		                    "TagB",// tag
		                    "OrderID0034",// key
		                    ("Hello MetaQ").getBytes());// body
		            SendResult sendResult = producer.send(msg);
		            System.out.println(sendResult);
			}
            
			producer.shutdown();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}
